package com.zzyl.nursing.job;

import com.zzyl.nursing.service.IReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 预约状态更新定时任务
 * 
 * @author ruoyi
 * @date 2025-07-25
 */
@Component("ReservationJob")
@Slf4j
public class ReservationJob {

    @Autowired
    private IReservationService reservationService;

    /**
     * 更新预约状态定时任务
     * 自动将过期的预约状态更新为"过期"状态
     */
    public void updateReservationStatus() {
        log.info("====== 开始执行预约状态更新定时任务 ======");
        try {
            int updatedCount = reservationService.updateExpiredReservations();
            log.info("====== 预约状态更新定时任务执行完成，更新了 {} 条记录 ======", updatedCount);
        } catch (Exception e) {
            log.error("====== 预约状态更新定时任务执行失败 ======", e);
            throw e; // 重新抛出异常，让定时任务框架记录失败日志
        }
    }
} 